import Vue from "vue";
import VueRouter from "vue-router";

Vue.use(VueRouter);

const routes = [
    {
        path: "/LoginNoPwd",
        name: "LoginNoPwd",
        component: () =>
            import ("../views/Login/LoginNoPwd.vue")
    },
    {
        path: "/login",
        name: "Login",
        component: () =>
            import ("../views/Login/Login.vue")
    },
    {
        path: "/",
        component: () =>
            import ("../views/Main.vue"),
        redirect: "/cameraPlay",
        meta: {
            title: "视频播放"
        },
        children: [{
                path: "/cameraPlay",
                component: () =>
                    import ("../views/cameraPlay/videoScreen/Index.vue"),
                meta: {
                    title: "视频播放"
                }
        },
            {
                path: "/mapMarkCamera",
                component: () =>
                    import ("../views/cameraPlay/mapMarkCamera/Index.vue"),
                meta: {
                    title: "地图展示"
                }
            },
            {
                path: "/ArcGIS",
                component: () =>
                    import ("../views/cameraPlay/ArcGIS/Index.vue"),
                meta: {
                    title: "ArcGIS地图"
                }
            },
            {
                path: "/playlogs",
                component: () =>
                    import ("../views/cameraPlay/playlogs/Index.vue"),
                meta: {
                    title: "视频播放日志"
                }
            },
            {
                path: "/playTask",
                component: () =>
                    import ("../views/cameraPlay/playTask/Index.vue"),
                meta: {
                    title: "播放任务"
                }
            },
            {
                path: "/playTask/editTask",
                component: () =>
                    import ("../views/cameraPlay/playTask/editTask/Index.vue"),
                meta: {
                    title: "编辑任务"
                }
            },
            {
                path: "/playTask/playAuto",
                component: () =>
                    import ("../views/cameraPlay/playTask/playAuto/Index.vue"),
                meta: {
                    title: "播放"
                }
            }
        ]
    },
    {
        path: "/videoRecord",
        component: () =>
            import ("../views/Main.vue"),
        // redirect: "/videoRecord",
        meta: {
            title: "视频录像"
        },
        children: [
        {
            path: "/videoRecord",
            component: () =>
                import ("../views/videoRecord/replay/Index.vue"),
            meta: {
                title: "录像回放"
            }
        },
            {
                path: "/videoProgram",
                component: () =>
                    import ("../views/videoRecord/videoProgram/Index.vue"),
                meta: {
                    title: "录像计划"
                }
            },
            {
                path: "/videoProgram/timeSeries",
                component: () =>
                    import ("../views/videoRecord/videoProgram/timeSeries/Index.vue"),
                meta: {
                    title: "时间序列"
                }
            },
        ]
    }, 
    {
        path: "/camera",
        component: () =>
            import ("../views/Main.vue"),
        meta: {
            title: "设备"
        },
        children: [{
                path: "/camera",
                component: () =>
                    import ("../views/deviceManage/camera/Camera.vue"),
                meta: {
                    title: "摄像机"
                }
            },
            {
                path: "/camera/CameraDetail",
                component: () =>
                    import ("../views/deviceManage/camera/CameraDetail.vue"),
                meta: {
                    title: "位置"
                }
            },
            {
                path: "/camera/applyBills",
                component: () =>
                    import ("../views/deviceManage/camera/applyBills/ApplyBillsIndex.vue"),
                meta: {
                    title: "票据"
                }
            },
            {
                path: "/camera/applyBills_no",
                component: () =>
                    import ("../views/deviceManage/camera/applyBills_no.vue"),
                meta: {
                    title: "无票据"
                }
            },
            // {
            //     path: "/videoProgram",
            //     component: () =>
            //         import ("../views/deviceManage/videoProgram/index.vue"),
            //     meta: {
            //         title: "录像计划"
            //     }
            // },
            // {
            //     path: "/videoProgram/timeSeries",
            //     component: () =>
            //         import ("../views/deviceManage/videoProgram/timeSeries/Index.vue"),
            //     meta: {
            //         title: "时间序列"
            //     }
            // },
            {
                path: "/ydtBox",
                component: () =>
                    import ("../views/deviceManage/ydtBox/YdtBox.vue"),
                meta: {
                    title: "一点通盒子"
                }
            },
            {
                path: "/ydtBox/ydtDeviceList",
                component: () =>
                    import ("../views/deviceManage/ydtBox/YdtDeviceList.vue"),
                meta: {
                    title: "盒子挂载设备"
                }
            },
            {
                path: "/gateway",
                component: () =>
                    import ("../views/deviceManage/gateway/Gateway.vue"),
                meta: {
                    title: "一点通网关"
                }
            },
            {
                path: "/gateway/gatewayDeviceList",
                component: () =>
                    import ("../views/deviceManage/gateway/GatewayDeviceList.vue"),
                meta: {
                    title: "网关挂载设备"
                }
            },
            {
                path: "/mwGateway",
                component: () =>
                    import ("../views/deviceManage/mwGateway/index.vue"),
                meta: {
                    title: "高速公路网关"
                }
            },
            {
                path: "/mwGateway/mwGatewayDeviceList",
                component: () =>
                    import ("../views/deviceManage/mwGateway/mwGatewayDeviceList.vue"),
                meta: {
                    title: "高速公路网关挂载设备"
                }
            },
            {
                path: "/statusMsg",
                component: () =>
                    import ("../views/deviceManage/statusMsg/Index.vue"),
                meta: {
                    title: "状态消息"
                }
            },
        ]
    }, {
        path: "/hostList",
        component: () =>
            import ("../views/Main.vue"),
        meta: {
            title: "流媒体主机"
        },
        children: [{
                path: "/hostList",
                component: () =>
                    import ("../views/hostManage/hostList/HostIndex.vue"),
                meta: {
                    title: "主机列表"
                }
            },
            {
                path: "/hostList/HostDevice",
                component: () =>
                    import ("../views/hostManage/hostList/coms/HostDevice.vue"),
                meta: {
                    title: "主机分配的设备"
                }
            },
            {
                path: "/hostList/SipDevice",
                component: () =>
                    import ("../views/hostManage/hostList/coms/SipDevice.vue"),
                meta: {
                    title: "SIP主机挂载的设备"
                }
            },
            {
                path: "/hostList/TotalFlow",
                component: () =>
                    import ("../views/hostManage/hostList/coms/TotalFlow.vue"),
                meta: {
                    title: "总流量"
                }
            },
            {
                path: "/hostList/SubFlow",
                component: () =>
                    import ("../views/hostManage/hostList/coms/subFlow/SubFlowIndex.vue"),
                meta: {
                    title: "分流量"
                }
            },
            {
                path: "/deviceList",
                component: () =>
                    import ("../views/hostManage/deviceList/Index.vue"),
                meta: {
                    title: "分配设备列表"
                }
            },
            {
                path: "/deviceListUndistributed",
                component: () =>
                    import ("../views/hostManage/deviceListUndistributed/Index.vue"),
                meta: {
                    title: "未分配设备列表"
                }
            },
            {
                path: "/videoRequestLog",
                component: () =>
                    import ("../views/hostManage/videoRequestLog/Index.vue"),
                meta: {
                    title: "视频请求日志"
                }
            }
        ]
    }, {
        path: "/",
        component: () =>
            import ("../views/Main.vue"),
        redirect: "/allAdmin",
        meta: {
            title: "开放平台"
        },
        children: [{
                path: "/allAdmin",
                component: () =>
                    import ("../views/openPlatform/allAdmin/AllAdmin.vue"),
                meta: {
                    title: "开发者"
                }
            },
            {
                path: "/allAdmin/adminToApp",
                component: () =>
                    import ("../views/openPlatform/allAdmin/adminToApp/AdminToApp.vue"),
                meta: {
                    title: "该开发者的应用"
                }
            },
            {
                path: "/allApplication",
                component: () =>
                    import ("../views/openPlatform/allApplication/AllApplication.vue"),
                meta: {
                    title: "应用"
                }
            },
            {
                path: "/APPOperationRecord",
                component: () =>
                    import ("../views/openPlatform/APPOperationRecord.vue"),
                meta: {
                    title: "应用操作记录"
                }
            }
        ]
    }, {
        path: "/",
        component: () =>
            import ("../views/Main.vue"),
        redirect: "/allApi",
        meta: {
            title: "API权限"
        },
        children: [{
                path: "/allApi",
                component: () =>
                    import ("../views/api/allApi/Index.vue"),
                meta: {
                    title: "API列表"
                }
            },
            {
                path: "/apiAccess",
                component: () =>
                    import ("../views/api/ApiAccess.vue"),
                meta: {
                    title: "API访问统计"
                }
            },
            // {
            //     path: 'backgroundResourcesList',
            //     component: () => import('../views/openPlatform/backgroundResourcesList/BRList.vue'),
            //     meta: {
            //         title: '后台资源列表'
            //     }
            // },
            {
                path: "/ipBlacklist",
                component: () =>
                    import ("../views/api/IpBlacklist.vue"),
                meta: {
                    title: "频繁访问IP黑名单"
                }
            }
        ]
    }, {
        path: "/",
        component: () =>
            import ("../views/Main.vue"),
        redirect: "/adminSetting",
        meta: {
            title: "系统设置"
        },
        children: [{
                path: "/adminSetting",
                component: () =>
                    import ("../views/systemSetting/AdminSetting.vue"),
                meta: {
                    title: "我的设置"
                }
            },
            {
                path: "/systemParamSetting",
                component: () =>
                    import ("../views/systemSetting/SystemParamSetting.vue"),
                meta: {
                    title: "系统参数设置"
                }
            },
            {
                path: "/adminList",
                component: () =>
                    import ("../views/systemSetting/adminList/AdminList.vue"),
                meta: {
                    title: "管理员"
                }
            },
            {
                path: "/roleManage",
                component: () =>
                    import ("../views/systemSetting/roleManage/RoleManage.vue"),
                meta: {
                    title: "角色"
                }
            },
            {
                path: "/organization",
                component: () =>
                    import ("../views/systemSetting/org/Org.vue"),
                meta: {
                    title: "分组"
                }
            },
            /* {
              path: "OAuth2",
              component: () => import("../views/systemSetting/OAuth2/OAuth2.vue"),
              meta: {
                title: "OAuth2用户"
              }
            }, */
            {
                path: "/operationRecord",
                component: () =>
                    import ("../views/systemSetting/OperationRecord.vue"),
                meta: {
                    title: "管理员操作记录"
                }
            },
            {
                path: "/errorSystemCode",
                component: () =>
                    import ("../views/systemSetting/ErrorSystemCode.vue"),
                meta: {
                    title: "系统错误码"
                }
            },
            {
                path: "/test",
                name: "test",
                component: () =>
                    import ("../views/test.vue")
            },
        ]
    },  {
        path: "*",
        component: () =>
            import ("../views/NotFound/NotFound.vue")
    },
    // {
    //     path: "/test",
    //     name: "test",
    //     component: () =>
    //         import ("../views/test.vue")
    // },
];

//获取原型对象上的push函数
const originalPush = VueRouter.prototype.push;
//修改原型对象中的push方法
VueRouter.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err);
};

const router = new VueRouter({
    mode: "hash",
    base: process.env.BASE_URL,
    scrollBehavior(to, from, savedPosition) {
        if (savedPosition) {
            return savedPosition;
        } else {
            return { x: 0, y: 0 };
        }
    },
    routes
});

export default router;